import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import store from './store'
import axios from 'axios';
import utils from '@/utils/utils.js';

axios.defaults.baseURL = 'http://127.0.0.1:8088';
const app = createApp(App)
app.config.globalProperties.$baseURL = 'http://127.0.0.1:8088';

app.use(router)
app.use(Antd)
app.use(store)

app.mount('#app')

/**
 * axios拦截器
 */
axios.interceptors.request.use(function (config) {
    console.log('请求参数：', config);
    const token = store.state.user.token;
    if (!utils.isEmpty(token)) {
        config.headers.token = token;
        console.log("请求headers增加token:", token);
    }
    return config;
}, error => {
    return Promise.reject(error);
});

axios.interceptors.response.use(function (response) {
    console.log('返回结果：', response);
    return response;
}, error => {
    console.log('返回错误：', error.message);
    return Promise.reject(error);
});
